#ifndef __LCDINIT_H
#define	__LCDINIT_H

#include "main.h"

#define GC9A01_CMD_CASETF 0x2A
#define GC9A01_CMD_RASETF 0x2B
#define GC9A01_CMD_RAMWR  0x2C

#define io_writ 0
#define io_read 1

#define LCD_CSHigh()        SPI1_CS_GPIO_Port->BSRR = SPI1_CS_Pin
#define LCD_CSLow()         SPI1_CS_GPIO_Port->BRR = SPI1_CS_Pin
#define LCD_SDAHigh()       SPI1_MOSI_GPIO_Port->BSRR = SPI1_MOSI_Pin
#define LCD_SDALow()        SPI1_MOSI_GPIO_Port->BRR = SPI1_MOSI_Pin
#define LCD_SCLHigh()       SPI1_SCL_GPIO_Port->BSRR  = SPI1_SCL_Pin
#define LCD_SCLLow()        SPI1_SCL_GPIO_Port->BRR  = SPI1_SCL_Pin 
#define LCD_DCXHigh()       SPI1_DCX_GPIO_Port->BSRR = SPI1_DCX_Pin
#define LCD_DCXLow()        SPI1_DCX_GPIO_Port->BRR = SPI1_DCX_Pin
#define LCD_RSTHigh()       LCD_RESET_GPIO_Port->BSRR = LCD_RESET_Pin  
#define LCD_RSTLow()        LCD_RESET_GPIO_Port->BRR = LCD_RESET_Pin

#define LCD_WRHigh()        LCD_WR_GPIO_Port->BSRR = LCD_WR_Pin  
#define LCD_WRLow()         LCD_WR_GPIO_Port->BRR = LCD_WR_Pin
#define LCD_RDHigh()        LCD_RD_GPIO_Port->BSRR = LCD_RD_Pin  
#define LCD_RDLow()         LCD_RD_GPIO_Port->BRR = LCD_RD_Pin
#define PAR_CSHigh()        LCD_CS_GPIO_Port->BSRR = LCD_CS_Pin
#define PAR_CSLow()         LCD_CS_GPIO_Port->BRR = LCD_CS_Pin


/*#define LCD_CSHigh()         {    GPIOA->ODR = GPIOA->ODR | 1<<5 ;     }
#define LCD_CSLow()          {    GPIOA->ODR = GPIOA->ODR & 0XFFFFFFDF ;     }
#define LCD_SDAHigh()        {    GPIOA->ODR = GPIOA->ODR | 1<<7 ;     }
#define LCD_SDALow()         {    GPIOA->ODR = GPIOA->ODR & 0XFFFFFF7F ;     }
#define LCD_SCLHigh()        {    GPIOC->ODR = GPIOC->ODR | 1<<4 ;     }
#define LCD_SCLLow()         {    GPIOC->ODR = GPIOC->ODR & 0XFFFFFFEF ;     }
#define LCD_DCXHigh()        {    GPIOC->ODR = GPIOC->ODR | 1<<5 ;     }
#define LCD_DCXLow()         {    GPIOC->ODR = GPIOC->ODR & 0XFFFFFFDF ;     }
#define LCD_RSTHigh()        {    GPIOA->ODR = GPIOA->ODR | 1<<4 ;     }  
#define LCD_RSTLow()         {    GPIOA->ODR = GPIOA->ODR & 0XFFFFFFEF ;     } */  
//*****************************************
void wr_cmd_4spi_8bcs(uint8_t par);
void wr_dat_4spi_8bcs(uint8_t par);
void wr_num(uint8_t par);
void wr_c2c();
//******************************************
void wr_cmd_parall2_8(uint16_t par);//DB8-1
void wr_dat_parall2_8(uint16_t par);
void wr_cmd_parall1_16(uint16_t par);
void wr_dat_parall1_16(uint16_t par);
void wr_displ_parall2_18(uint16_t color1,uint16_t color2);
//*****************************************
void wr_cmd_parall1_8(uint16_t par);//DB8-1
void wr_dat_parall1_8(uint16_t par);
void wr_displ_parall1_8(uint8_t color);
void wr_cmd_7775r(uint16_t par);
void wr_dat_7775r(uint16_t par);
void Write(uint8_t com, uint16_t par);
//*****************************************
void rd_parall1_8(uint8_t c, uint8_t *d, uint32_t l);
//******************************************
void C240DLBH_Init(void);
void C200CLAP_01_100C(void);
void WV018LZQ(void);
void initial(void);
void lcd_main(void);
//void Filllcd_Area(uint16_t _usX, uint16_t _usY, uint16_t _usWidth , uint16_t _usHeight, uint16_t color);
void Filllcd_Area(uint32_t color);

#endif